<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page import="com.mongodb.client.MongoCursor,org.bson.Document,java.util.Date,java.text.*" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>任务列表</title>
</head>
<body>
	<%MongoCursor<Document> taskList = (MongoCursor<Document>)request.getAttribute("result");%>
	<jsp:include page="../navbar.jsp" />
	<div class="container-fluid">
		<div class="row mt15">
			<div class="col-md-10 col-md-offset-1">
			<%if(!taskList.hasNext()) {%>
				<div class="col-md-6 col-md-offset-3">
					<div class="panel panel-default">
	                	<div class="panel-body">	                		
							<h5 class="text-center text-muted">暂无任务</h5>
						</div>
					</div>
				</div>
			<%} else {
					while(taskList.hasNext()) {
						Document document = taskList.next();
						String name = document.getString("name");
						Date date = document.getDate("createtime"); 
						SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm");
						String createtime = formatter.format(date);
						String teachername = document.getString("teachername");
						boolean isfinish = document.getBoolean("isfinish");
						String courseclassname = document.getString("courseclassname");
				%>
				<div class="col-md-3">
					<div class="panel" style="border-bottom:4px solid #337ab7;box-shadow: -5px -5px 5px #eee;">
						<div class="panel-body text-center">
		                  <div class="clearfix discover">
		                   	<div class="pull-left text-info">
		                        <em class="fa fa-flag"></em> 班级:<%=courseclassname %>
		                     </div>
		                     <div class="pull-right">
		                     	<a href="taskDetail.jsp?_id=<%=document.getObjectId("_id") %>">
		                     		<button type="button" class="btn btn-default" data-toggle="tooltip" data-placement="top" title="查看详情">
										<em class="fa fa-search"></em>
									</button>
		                     	</a>							
		                     </div>
		                  </div>
		                  <div class="mt38 mb38">
		                  	  <a class="text-muted file-manage">
			                     <h4><em class="fa fa-flask"></em> <%=name %></h4>
			                  </a>
		                  </div>
		                  <div class="clearfix discover">
		                  	 <div class="pull-left text-muted" style="font-size:12px">
		                        <em class="fa fa-clock-o"> <%=createtime %></em> 
		                     </div>
		                     <div class="pull-right">
		                     	<%if(isfinish) {%>
		                     		<span class="badge" style="background-color:#5cb85c">已完成</span>
		                     	<%}
		                     	else {%>
		                     		<span class="badge" style="background-color:#f0ad4e">未完成</span>
		                     	<%} %>
		                     </div>
		                  </div>
		               </div>		               
					</div>
				</div>
				<%} %>
			<%} %>
			</div>
		</div>
	</div>
	<script src="http://cdn.static.runoob.com/libs/jquery/2.1.1/jquery.min.js"></script>
	<script src="http://cdn.static.runoob.com/libs/bootstrap/3.3.7/js/bootstrap.min.js"></script>
	<script>
		$(function () { $("[data-toggle='tooltip']").tooltip(); });
	</script>
</body>
</html>